#!/usr/bin/env bash

# mlaine@sdfeu

source '../say.sh'

nick="$1"
args=("${@:3}")

if [[ "${#args[@]}" -ge 2 && "${args[-2]}" = '>' &&
    ! "${args[-1]}" =~ '#' ]]; then
    ch="${args[-1]}"
else
    ch="$nick"
fi

msg=(
    '/*'
    'Hi there! I am the sdf irc network bot.'
    'I provide many commands answering questions frequently asked.'
    "The most important of these is the command '!faq'."
    "All available commands can be listed with '!commands'."
    ' '
    'Before going any further, PLEASE do spend some time with me here'
    'in private and experiment with the commands. Also note that at'
    'any time you may /msg BASHy2[-EU] and avoid spammming on channels.'
    'Any questions left unanswered are welcomed in #helpdesk.'
    ' '
    "IF YOU FORGOT YOUR PASSWORD ISSUE '!faq forgot'."
    ' '
    'This message is sent on join to anyone who has not been active on'
    'any channel BASHy2[-EU] is on.'
    '*/'
)

say "$ch" "${msg[@]}" 

